<?php

class Euso_Module
{
	protected $_active = null;
	protected $_idname = null;
	protected $_name = null;
	protected $_namespace = NULL;
	protected $_version = NULL;
	protected $_description = NULL;
	protected $_configs = NULL;
	protected $_installedVersion = NULL;


    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }


    public function __set($name, $value)
    {
        $method = 'set' . ucfirst($name);
        $this->$method($value);
    }
    public function __get($name)
    {
        $method = 'get' . ucfirst($name);
        return $this->$method();
    }

    public function setOptions(array $options)
    {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }


	public function setActive($active = false)
	{
		$this->_active = $active;
		return $this;
	}
	public function setIdName($idname = null)
	{
		$this->_idname = $idname;
		return $this;
	}
	public function setName($name = null)
	{
		$this->_name = $name;
		return $this;
	}
	public function setNamespace($namespace = null)
	{
		$this->_namespace = $namespace;
		return $this;
	}
	public function setVersion($version = null)
	{
		$this->_version = $version;
		return $this;
	}
	public function setDescription($desc = null)
	{
		$this->_description = $desc;
		return $this;
	}
	public function setConfigs($configs = null)
	{
		$this->_configs = $configs;
		return $this;
	}
	public function setInstalledVersion($version = NULL)
	{
		$this->_installedVersion = $version;
		return $this;
	}


	public function getActive()
	{
		return $this->_active;
	}
	public function getIdName()
	{
		return $this->_idname;
	}
	public function getName()
	{
		return $this->_name;
	}
	public function getNamespace()
	{
		return $this->_namespace;
	}
	public function getVersion()
	{
		return $this->_version;
	}
	public function getDescription()
	{
		return $this->_description;
	}
	public function getConfigs()
	{
		return $this->_configs;
	}
	public function getInstalledVersion()
	{
		return $this->_installedVersion;
	}

	public function checkVersions()
	{
		return $this->_installedVersion == $this->_version ? TRUE : FALSE;
	}
	public function hasValidInstalledVersion()
	{
		return empty($this->_installedVersion) ? FALSE : TRUE;
	}
}